//
//  CityBrandList.m
//  cityStar
//
//  Created by joyban on 14-12-23.
//  Copyright (c) 2014年 tiny. All rights reserved.
//

#import "CityBrandList.h"
#import "CityBrandListCell.h"
#import "BranddetailsViewController.h"
#import "RepairAndHomeViewController.h"

#import "UIColor+FlatUI.h"
#import "HWSearchViewController.h"

NSString *const ListTableViewCellID = @"ListCell";

@interface CityBrandList ()

@end

@implementation CityBrandList
@synthesize ListTableView,title;

-(void)viewWillAppear:(BOOL)animated
{
    [ListTableView reloadData];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = title;
    [self addBackButton];
    [self setUpTableViews];
    
    __weak typeof(self)weakSelf = self;
    [self addRightButtonWithTitle:@"" actionBlock:^{
        HWSearchViewController *hwSearchVC = [[HWSearchViewController alloc]init];
        hwSearchVC.hidesBottomBarWhenPushed = YES;
        [weakSelf.navigationController pushViewController:hwSearchVC animated:YES];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)setUpTableViews
{
    [ListTableView registerNib:[CityBrandListCell nib] forCellReuseIdentifier:ListTableViewCellID];
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [CityBrandListCell heightOfTableCell];
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView * sectionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 220)] ;
    [sectionView setBackgroundColor:[UIColor colorFromHexCode:@"F6F5F1"]];
    
    
    return sectionView;
}

#pragma mark - UITableViewDelegate and UITableViewDataSource

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
        CityBrandListCell *ListdetailCell = [tableView dequeueReusableCellWithIdentifier:ListTableViewCellID];
//        ListdetailCell.selectionStyle = UITableViewCellSelectionStyleBlue;
        return ListdetailCell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    BranddetailsViewController *branddetail = [[BranddetailsViewController alloc]init];
    [self.navigationController pushViewController:branddetail animated:YES];
}
//    RepairAndHomeViewController *HomeController = [[RepairAndHomeViewController alloc]init];
//    [self.navigationController pushViewController:HomeController animated:YES];
//}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
